package com.example.demo;

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class hello3 {
    public static void main(String[] args) {
        List<Integer> integers = Arrays.asList(1, 2, 3, 4);
        Iterator<Integer> iterator = integers.iterator();
        while (iterator.hasNext()){
            Integer next = iterator.next();
            System.out.println(next);
//            try {
                iterator.remove();
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
            System.out.println(integers);
        }
    }
}
